﻿
namespace EasyNet.Solr.Commons
{
    using System.Runtime.InteropServices;

    [StructLayout(LayoutKind.Explicit)]
    public struct DoubleConverter
    {
        [FieldOffset(0)]
        private double d;
        [FieldOffset(0)]
        private long l;

        public static double ToDouble(long value, ref DoubleConverter converter)
        {
            converter.l = value;

            return converter.d;
        }

        public static long ToLong(double value, ref DoubleConverter converter)
        {
            converter.d = value;

            return converter.l;
        }
    }
}
